import { Trace } from "@/core";
import { IBaseTrace, TraceOptions } from "index";

let instance: IBaseTrace;

export const init = (options: TraceOptions) => {
  if (!options.appId) {
    console.error(new Error("appId is required"));
    return;
  }
  if (instance && instance.appId === options.appId) {
    return instance;
  }
  instance = Trace.init(options);
  options.debug && console.log("instance: ", instance);
  return instance;
};

globalThis.$traceInit = init;
